import 'package:flutter/material.dart';
import 'package:ui_templates/app_theme.dart';

class TopButtonAndSkip extends StatefulWidget {
  TopButtonAndSkip(
      {super.key,
      required this.animationController,
      required this.goBack,
      required this.skipPages});

  final AnimationController animationController;
  void Function() goBack;
  void Function() skipPages;

  @override
  State<TopButtonAndSkip> createState() => _TopButtonAndSkipState();
}

class _TopButtonAndSkipState extends State<TopButtonAndSkip> {
  @override
  Widget build(BuildContext context) {
    //这里是和Splash同一样
    var topAnimation =
        Tween<Offset>(begin: (const Offset(0, -2)), end: const Offset(0, 0))
            .chain(CurveTween(curve: Curves.easeInOut))
            .chain(
              CurveTween(curve: const Interval(0, 0.2)),
            )
            .animate(widget.animationController);
    return Positioned(
      top: 40,
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 8.0),
        child: Container(
          width: MediaQuery.of(context).size.width - 16,
          height: 50,
          child: SlideTransition(
            position: topAnimation,
            child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                      width: 40,
                      height: 40,
                      child: Material(
                        color: const Color.fromRGBO(245, 235, 226, 1),
                        child: IconButton(
                            splashColor: Colors.grey,
                            icon: Icon(Icons.arrow_back),
                            onPressed: widget.goBack),
                      )),
                  Container(
                    width: 50,
                    height: 40,
                    child: TextButton(
                      child: const Text("Skip", style: AppTheme.caption),
                      onPressed: widget.skipPages,
                    ),
                  ),
                ]),
          ),
        ),
      ),
    );
  }
}
